from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import set_cutscene
from items.hair import Hair

class Mirror(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        #ADD HAIR ITEM HERE
        
        # build list of actions
        self.add_action(StepBack)
        self.add_action(PullOutHair)
    
    # return description of room.
    def get_description(self):
        return "MacGyver pauses to admire his beautiful flowing mullet."
    
    # return image of room
    def get_image(self):
        return 'mirror.jpg'


class MirrorHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Mirror

# define actions for this room

class StepBack(Action):
    def __init__(self):
        Action.__init__(self, "StepBack")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Step Back"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'wardensoffice'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class PullOutHair(Action):
    def __init__(self):
        Action.__init__(self, "pull_out_hair")    # do basic initialization for every action
        self.tookHair = False
        
    # this method gets called when action executed.  can be overridden in subclass
    def do_action(self,game,room,request):
        if game.get_player().can_pickup():
            self.tookHair = True
            game.get_player().add_item(Hair())
            set_cutscene("You pulled a few long, strong strands of hair.")
        return
    
    # should this action be available to player?
    def is_enabled(self):
        return not self.tookHair
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Pull Out Strands of Hair"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"